package com.helei.test;

public class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("继承Runnable接口，创建描述任务对象，实现多线程");
    }

    public static void main(String[] args) {
        //2.实现Runnable接口
        Thread t1 = new Thread(new MyRunnable());
        t1.start();
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("使用Runnable接口，创建匿名内部类实现");
            }
        });
        String name = t2.getName();
        System.out.println(name);
        System.out.println(t2.getId());
        t2.start();
        Thread t3 = new Thread(new MyRunnable());
        t3.start();
        System.out.println(t1.getName()+t3.getName());
    }
}

